define(["require", 'config/appregister', 'business/login/service/http', "jquery", "domReady"], function(require, app, httpServices) {
	app.controller('resetCtrl', function($scope, $state, $stateParams) {
		//提交修改的密码
		$scope.password='';
		$scope.infoTip='';
		$scope.passWords = function() {
			var regex_passwd = /^[\w]{6,18}$/;
			if($scope.password == "") {
				$scope.infoTip='密码不能为空';
			} else if(regex_passwd.test($scope.password)) {
				$scope.infoTip='';
				return true;
			} else {
				$scope.infoTip='密码为6-18个字符';
			}
		};
		$scope.setnewpswd = function() {
			if(!angular.isUndefined($stateParams.token)) {
				$scope.verifyToken = $stateParams.token
			}
			if($scope.passWords()){
				var req = {
					type:'POST',
					uri:'forgetPasswdByPhoneWithCommitNewPasswd',
					data:{
						newPasswd:$scope.password,
						verifyToken: $scope.verifyToken
					}
				};
				httpServices.getemlcodeHttpService(req).success(function(response){
					if(response.code==0) {
						$state.go("eng.loginedReseted");
					}else {
						alert(response.msg);
					}
				}).error(function(response){
					$scope.infoTip="提交修改密码失败";
				})
			}
		};

	})
});